Input signal discrimination method

ABSTRACT

An input signal discrimination method is provided wherein the on/off state of an AC input signal is discriminated. 
     An AC input signal (1) is input to a processor (21) through a photocoupler (13). The processor (21) counts pulses in a time for which the AC input signal (1) remains above a predetermined threshold level, and a time for which the signal remains below the predetermined threshold level. When the number of pulses counted while the signal remains above the predetermined threshold level is larger than a previously calculated number, it is decided that the AC input signal is on, and when the number of pulses counted while the signal remains below the predetermined threshold level is larger than a previously calculated value, it is decided that the AC input signal is off. Consequently, the on/off state of the AC input signal can be accurately discriminated in a short period of time.

D E S C R I P T I 0 N

1. Technical Field

The present invention relates to an input signal discrimination methodfor discriminating an AC input signal by a PLC (programmable logiccontroller) or the like, and more particularly to an input signaldiscrimination method for discriminating the state of an AC input signalby counting pulses.

2. Background Art

FIG. 4 shows an input circuit conventionally used to discriminate an ACinput signal by a PLC or the like. In the FIG., 1 represents an AC inputsignal, 10 represents an input circuit, and 20 represents a PLC forprocessing the input signal.

The input circuit 10 includes a rectifier circuit 11 for carrying out afull-wave rectification of the input signal, a resistor R and acapacitor C for smoothing the signal, and a photocoupler 12 to which thesmoothed signal is supplied, to thereby separate a DC output from the ACinput signal 1. A resistor R1, in cooperation with the resistor R,divides the voltage of the AC input signal 1 to lower the output level.The PLC discriminates the state, and carries out a sequence processing,of the AC input signal 1, based on the signal from the photocoupler 12.

With this circuit configuration, however, the output of the inputcircuit 10 must be a ripple-free signal, and therefore, the timeconstant R1·C of the circuit must be large. As a result, the responsetime of the input circuit 10 is prolonged and it is difficult to obtaina value shorter than three cycles of the alternating current of the ACinput signal.

SUMMARY OF THE INVENTION

The object of the present invention is to provide an input signaldiscrimination method which solves the above-mentioned problem and inwhich the state of an AC input signal is discriminated by countingpulses.

To solve the above problem, the present invention provides an inputsignal discrimination method of discriminating an AC input signal. Themethod includes a step of carrying out a pulse count in a time for whichthe AC input signal remains above a predetermined threshold level and atime for which the AC input signal remains below the predeterminedthreshold level. Another step includes deciding that the AC input signalis on by counting the number of pulses the AC input signal remains abovethe predetermined threshold level and determines that the number ofpulses counted is larger than a previously calculated number of pulses.The method also includes deciding that the AC input signal is off whenthe number of pulses counted while the AC input signal remains below thepredetermined threshold level is larger than the previously calculatednumber of pulses.

When the AC input signal is on, the signal level remains higher than thethreshold level for a predetermined time, and therefore, this high-leveltime is discriminated by the number of pulses counted to discriminatethe signal on state.

Alternatively, when the AC input signal is off, the signal level remainslower than the threshold level for a predetermined time, and therefore,this low-level time is discriminated by the number of pulses counted todiscriminate the signal off state.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating an embodiment of the presentinvention;

FIG. 2 is a timing chart for illustrating the embodiment of theinvention;

FIG. 3 is a flowchart illustrating the embodiment of the invention; and

FIG. 4 is a diagram showing an example of conventional prior art inputcircuit.

DESCRIPTION OF THE PREFERRED EMBODIMENT

An embodiment of the present invention will be described with referenceto the drawings.

FIG. 1 is a block diagram illustrating an embodiment of the presentinvention. In the FIG., 1 denotes an AC input signal, the on or offstate of which is determined by the effective value thereof, and 10represents an input circuit which receives the AC input signal 1 andoutputs a DC signal. The input circuit 10 includes resistors R and R1which carry out a voltage division of the input signal and apply thedivided voltage to a photocoupler 13. The photocoupler 13 includeslight-emitting diodes connected in an inverse-parallel fashion as shownin the figure, for rectifying the AC input by turning on a transistorwhen a current having a level higher than the threshold level flows ineither direction. Vcc designates a voltage applied to a logic circuitand is usually +5 V, and R2 denotes a voltage detection resistor.Accordingly, the input circuit outputs, from an output terminal Athereof, a signal obtained by carrying out a full-wave rectification ofthe AC input signal 1. Numeral 21 denotes a processor of a PLC(programmable logic controller) for global control of the PLC, 22denotes a ROM for storing a monitor program for the PLC, a sequenceprogram, and the like, and 23 denotes a RAM for storing various data anda signal output from the input circuit 10 through the processor 21.

The output of the input circuit 10, which is connected to an input portof the processor 21, is read by the processor 21 in a cycle shorter thanone cycle of the AC input signal 1. When the AC input signal 1 is on,the output level of the input circuit 10 remains higher than thethreshold level for longer than a predetermined time, and accordingly,the signal on time is prolonged. When the AC input signal is off, thetime for which the output level remains below the threshold level isprolonged, and therefore, this time is counted by the processor todiscriminate the state of the AC input signal.

FIG. 2 is a timing chart illustrating the embodiment of the invention.In the figure, C1 represents the AC input signal 1 in FIG. 1, and C2represents the voltage across the resistor R1 the ratio of magnitudebetween the two is actually about 20:1 although the ratio illustrated isabout 2:1. Straight lines L1 and L2 indicate the threshold levels of thephotocoupler 13, OUTPUT OF INPUT CIRCUIT indicates the output waveformat terminal A of the input circuit 10 in FIG. 1, and READ CYCLErepresents the timing at which the processor 21 reads the output signalof the input circuit 10.

When the AC input signal 1 is on, the voltage C2 across the resistor R1exceeds and remains higher than the threshold level for longer than apredetermined time. Accordingly, if the input signal is read by theprocessor 21 in the above-mentioned read cycle, the on state continuesfor longer than a predetermined time, and as a result, the processor 21decides that the input signal is on.

When the AC input signal 1 is off, the voltage across the resistor R1 isbelow the threshold level, or if higher than the threshold level, thetime for which the voltage remains above the threshold level is shorterthan a predetermined time. Therefore, the off time of the output signalof the input circuit is prolonged, and when the signal is read by theprocessor 21 in the read cycle mentioned above, the off state continuesfor longer than a predetermined time, and as a result, the processordecides that the input signal is off.

Referring to FIG. 2, assuming that the curve C2 represents the boundarybetween the signal on and off states, then

    ts=(1/N)·tx=(1/n)·Th

stands, wherein

ts: the interval of the read cycle of the processor;

N: the time for which the on state of the AC input signal continues;

Th: the half cycle of the AC input signal;

n: the number of read cycles during one half cycle of the AC inputsignal.

Namely, when the input signal remains on for longer than a time N, theprocessor decides that the AC input signal 1 is on. Alternatively, whenthe input signal remains off for longer than a time (n-N+1), then it isdetermined that the AC input signal is off.

Accordingly, the processor 21 can discriminate the state of the AC inputsignal within the time (Th+tx), and thus the response time can beshortened.

FIG. 3 is a flowchart illustrating the embodiment of the invention. Thenumber following the letter "S" indicates the number of the step.

[S1]The processor is initialized.

[S2]The signal input from the input circuit 10 is read.

[S3]It is determined whether the input signal is on or off. When thesignal is on, the program proceeds to S4, and when the signal is off,the program proceeds to S6.

[S4]It is determined whether the on state of the input signal iscontinued for a time N. If yes, it is decided at S5 that the AC inputsignal 1 is on, and if no, as the state of the signal has not changed,the flow returns to S2.

[S6]Since the input signal is off, it is determined whether the offstate is continued for a time (n-N+1). If yes, at S7 it is decided thatthe AC input signal 1 is off, and if no, as the state of the signal hasnot changed, the flow returns to S2.

Accordingly, the input signal from the input circuit 10 is read in acycle ts, and the state of the AC input signal 1 is discriminated.

In the foregoing description, the photocoupler has light-emitting diodesconnected in parallel and having opposite polarities, alternatively, aphotocoupler including a single light-emitting diode may be used withthe addition of a rectifier circuit provided before stage resistor R,thus forming a similar circuitry.

Moreover, the signal from the input circuit may be connected to theinput port of the processor through a bus. Such a construction isparticularly practical when the number of input signals is large,because the number of input ports is relatively small.

As described above, the construction of the present invention is suchthat the state of the AC input signal is discriminated by countingpulses, and accordingly, the response time is shortened and componentssuch as a capacitor or the like can be omitted.

We claim:
 1. An input signal discrimination method of discriminating anAC input signal, said method comprising the steps of:a) carrying out apulse count during a time in which the AC input signal remains above apredetermined threshold level and during a time in which the AC inputsignal remains below the predetermined threshold level; b) deciding thatthe AC input signal is ON when the number of pulses counted while the ACinput signal remains above the predetermined threshold level is largethan a previously calculated number of pulses; and c) deciding that theAC input signal is OFF when the number of pulses counted while the ACinput signal remains below the predetermined threshold level is largerthan the previously calculated number of pulses.
 2. An input signaldiscrimination method according to claim 1, further comprising the stepof separating the AC input signal from a discrimination circuit by aphotocoupler.
 3. An input signal discrimination method according toclaim 2, wherein said step of separating the AC input signal isaccomplished by providing the photocoupler with light-emitting diodesconnected in parallel and having opposite polarities.